<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html" %>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<%@include file="/commons/page/codegen.jsp" %>
		<script type="text/javascript" src="${ctx}/js/gpoint/rdp/TimeSegment/timeSeg.js"></script>
		<title>TB_DOOR_TIMESEG管理列表</title>
	</head>
	<body>
		<div class="wrapper wrapper-content  animated fadeInRight col-sm-12">
			<div  class="toolbar-panel ">
				<div class="toolbar-box">
					<div class="toolbar-head clearfix">
						<!-- 顶部按钮 -->
						<div class="buttons"> 		
							<a class="btn btn-primary fa fa-search" href="javascript:void(0);" ><span>搜索</span></a>
							<%-- <a class="btn btn-primary fa fa-add"   href="${ctx}/rdp/TimeSegment/timeSeg/edit.htm" ><span>添加</span></a>
					        <a class="btn btn-primary fa fa-edit"   href="javascript:void(0);"  action="${ctx}/rdp/TimeSegment/timeSeg/edit.htm" ><span>编辑</span></a>	 
					        <a class="btn btn-primary fa fa-remove" href="javascript:void(0);"  action="${ctx}/rdp/TimeSegment/timeSeg/remove.htm"><span>删除</span></a> --%>
					
						  <a href="javascript:void(0);" class="btn btn-primary fa" id="savetime"  onclick ="savetime();" ><span>确定</span></a>
						</div>
						<!-- 收缩 -->
						<div class="tools">
							<a href="javascript:void(0);" class="collapse">
								<i class="bigger-180 fa  fa-angle-double-up"></i>
							</a>
						</div>
					</div>
					<!-- #查询条件-->
					<div class="toolbar-body" >
						<form role="form" class="search-form">
							<div  class="form-inline p-xxs">
								<div class="form-group">
									<label   class="search-label">时间段名称</label>:
									<input type="text"  name="Q^TIMESEGMS^SL"  class="form-control"  />
								</div> 
								<!--
								 <div class="form-group">
									<label class="search-label">开始时间 </label>:
									<input type="text" name="Q^ENDDATA^DL"  class="form-control date"  />
								</div>

								<div class="form-group">
									<label class="search-label">结束时间 </label>:
									<input type="text" name="Q^ENDDATA^DG"  class="form-control date"  />
								</div>
								-->
							</div>
						</form>
					</div><!--/ 查询条件-->
				</div>
			</div><!--/ 操作、查询-->
			<div class="jqGrid_wrapper">
				<table id="timeSegGrid" ></table>
				<div id="timeSegPager"></div>
			</div>
		</div>
	
	<script type="text/javascript">
	
	//alert("Env ok");
	//保存时间段
	function savetime(){
	//	alert("savetime 执行");
		//得到用户选择的列表
		 var ids = jQuery("#timeSegGrid").jqGrid('getGridParam','selarrrow');
	      if(ids.length != 1){
	   	   DialogUtil.confirm("请选择一个选项");
	   	   return;
	      }
	       var rowData= jQuery("#timeSegGrid").jqGrid("getRowData",ids[0]);
		 //获取数值
		 console.log(rowData); 
		  //var  type=ids[0];
		  var sn='${sn}';
		  var timeseg=rowData.timeseg;
		//  alert("_ctx="+__ctx);
		//拼凑一个大json ，只需要插入SN，和
		if(sn.length>0 && timeseg.length>0){
			//调用本机action 入库到sn_timesegment 表中
		     $.ajax({
			    		    	         	type: "get",
			    		    	         	   url: __ctx+"/rdp/snTimeSeq/snTimeSeq/save",
			    		    	         	    contentType: "application/json;charset=utf-8;",
			    		    	         	  data:{sn:sn,timeseg:timeseg},
			    		    	         	  dataType:"json",//注意不是datatype哦
			    		    	         	   async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
			    		    	         	 success: function(data) {
			    		    	         	         if(data.result==1){
			    		    	         		           alert("插入设备时间段表成功！");
			    		    	         	        }else{
			    		    	         	        	  alert("插入设备时间段表异常！");
			    		    	         	        } 
			    		    	         	       
			    		    	         	 
			    		    	         	 },
			    		    	         	 error: function(){
			    		    	         		  alert("插入设备时间段表失败！");
			    		    	              }
			    		    	         	 
			    		    	         	 }); 
	
	//Ajax请求判断  ,链接到 详情界面  显示字段就可以了 end
		}else{
			 alert("设备序列号或时间段为空！");
		}
		  
		
		
	
		
		
	}
	
	
	
	</script>
	
	</body>
	
</html>